package com.means.polymerize.assembly.aspect.logs;

import cn.hutool.core.date.DatePattern;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * <p>
 * 系统访问日志表
 * </p>
 *
 * @author xuhaifneg
 * @since 2021-10-21
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class SysLog {
    public static final String ID = "id";
    public static final String REQ_IP = "req_ip";
    public static final String REQ_LOCATION = "req_location";
    public static final String REQ_METHOD = "req_method";
    public static final String REQ_PATH = "req_path";
    public static final String REQ_TYPE = "req_type";
    public static final String REQ_TOKEN = "req_token";
    public static final String REQ_HEADER = "req_header";
    public static final String REQ_BODY = "req_body";
    public static final String REQ_API_ID = "req_api_id";
    public static final String REQ_USER_ID = "req_user_id";
    public static final String REQ_ROLE_ID = "req_role_id";
    public static final String REQ_START_TIME = "req_start_time";
    public static final String REQ_END_TIME = "req_end_time";
    public static final String REQ_COST_TIME = "req_cost_time";
    public static final String RES_MSG = "res_msg";
    public static final String RES_CODE = "res_code";
    public static final String RES_BODY = "res_body";
    public static final String USER_AGENT = "user_agent";
    public static final String CREATE_TIME = "create_time";
    /**
     * 请求ip
     */
    private String reqIp;
    /**
     * 请求地址
     */
    private String reqLocation;
    /**
     * 请求方式
     */
    private String reqMethod;
    /**
     * 请求路径
     */
    private String reqPath;
    /**
     * 类型(1=视图,2=数据)
     */
    private Integer reqType;
    /**
     * 请求token
     */
    private String reqToken;
    /**
     * 请求头
     */
    private String reqHeader;
    /**
     * 请求体
     */
    private String reqBody;
    /**
     * 请求接口id
     */
    private String reqApiId;
    /**
     * 请求用户id
     */
    private String reqUserId;
    /**
     * 请求角色名称
     */
    private String reqUserName;
    /**
     * 请求角色id
     */
    private String reqRoleId;
    /**
     * 请求开始时间
     */
    @JSONField(format = DatePattern.NORM_DATETIME_PATTERN)
    private LocalDateTime reqStartTime;
    /**
     * 请求结束时间
     */
    @JSONField(format = DatePattern.NORM_DATETIME_PATTERN)
    private LocalDateTime reqEndTime;
    /**
     * 花费时间，单位ms
     */
    private Long reqCostTime;
    /**
     * 响应描述
     */
    private String resMsg;
    /**
     * 响应状态码
     */
    private String resCode;
    /**
     * 响应体
     */
    private String resBody;
    /**
     * 请求客户端
     */
    private String userAgent;
    /**
     * 创建时间
     */
    private LocalDateTime createTime;
}
